<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3" xmlns:head="http://www.w3.org/1999/html">
<head th:include="public/public_css::public_css ('上架任务管理')" />

<body style="background-color: #f2f2f2;">
<div class="layui-fluid larry-wrapper">
    <div class="layui-card">
        <div class="layui-row layui-col-space30">
            <div class="layui-col-xs24">
                <form class="layui-form layui-card-header  layui-card-header-auto" id="searchForm">
                    <div class="layui-inline">
                        <label class="layui-form-label">ASN编号</label>
                        <input type="text" class="layui-input" id="asnbh" name="asnbh" placeholder="ASN编号"/>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">PO编号</label>
                        <input type="text" class="layui-input" id="dycgdbh" name="dycgdbh" placeholder="PO编号"/>
                    </div>
                    <div class="layui-inline">
                        <label class="layui-form-label">供应商名称</label>
                        <div class="layui-input-inline">
                            <input type="text" class="layui-input" id="gysid" name="gysid" placeholder="供应商名称"/>
                        </div>
                    </div>
                    <div class="layui-inline inline-search-btn">
                        <a class="layui-btn layui-btn-normal" data-type="reload" id="search_button"> 搜索 </a>
                    </div>
                    <div class="layui-inline inline-reset-btn">
                        <button type="reset" class="layui-btn layui-btn-primary" style="background-color: #40AFFE">重置</button>
                    </div>
                    <div class="moreSearch" style="display: none">
                        <div class="layui-inline">
                            <label class="layui-form-label">创建开始时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="cjsj_start" id="test5" placeholder="yyyy-MM-dd" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">  </label>
                            <div class="layui-input-inline" style="height:20px">
                                --
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">创建结束时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="cjsj_end" id="test6" placeholder="yyyy-MM-dd" />

                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">收货开始时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="shsj_start" id="test7" placeholder="yyyy-MM-dd" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">  </label>
                            <div class="layui-input-inline" style="height:20px">
                                --
                            </div>
                        </div>
                        <div class="layui-inline">
                            <label class="layui-form-label">收货结束时间</label>
                            <div class="layui-input-inline">
                                <input type="text" class="layui-input" name="shsj_end" id="test8" placeholder="yyyy-MM-dd" />

                            </div>
                        </div>
                    </div>
                </form>
               <!-- <div class="group-button" id="toolbar">

                    <a class="layui-btn layui-btn-sm layui-btn-normal add-btn">
                        <i class="layui-icon">&#x1005;</i> 生成
                    </a>
                </div>-->
                <div class="moreBtn"><i class="layui-icon layui-icon-triangle-d" style="color: #1E9FFF;"></i></div>
                <!--列表-->
                <section class="panel panel-padding layui-card-body" >
                    <div class="pro">
                        <table id="table" class="table text-nowrap"></table>
                    </div>
                </section>
            </div>
        </div>
    </div>
</div>
</body>


<div th:include="public/public_js::public_js"></div>
<style type="text/css">

</style>
<script>
    //	回车查询
    document.onkeydown = function(event) {
        e = event ? event : (window.event ? window.event : null);
        if (e.keyCode == 13) {
            //执行的方法
            $('#search_button').click();
        }
    };
    $(function () {
        $(".moreBtn").on("click",function () {
            $(".moreSearch").toggle();
        });
        $("#load").on("click",function(){
            //console.log(123);
            var data = {
                ids:[],
                page:0,
                rows:10
            };
            var xhr = new XMLHttpRequest();
            xhr.open("POST", "http://localhost:9191/zxsdwms/WmsDeliveryDetailsController/ShippingdetailsExcel", true);
            xhr.responseType = "blob";
            xhr.setRequestHeader('Accept', 'application/json');
            xhr.setRequestHeader('Content-Type', 'application/json');
            xhr.setRequestHeader('Charset', 'utf-8');
            xhr.onload = function() {
                if (this.status == 200) {
                    var name = xhr.getResponseHeader("Content-disposition");
                    name=decodeURI(name);
                    var filename = name.substring(20,name.length);
                    var blob = new Blob([xhr.response], {type: 'text/xls'});
                    var csvUrl = URL.createObjectURL(blob);
                    var link = document.createElement('a');
                    link.href = csvUrl;
                    link.download = filename;
                    link.click();
                }
            };
            xhr.send(JSON.stringify({
                "ids": [],
                "page":0,
                "rows":10
            }));
        })
    });
    layui.use(['list','layer','zzpUtils','jquery','laydate'],function () {
        var zzpUtils= layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;
        window.operateEvent = {
            "click #searchRow": function (e, value, row, index) {//行按钮查看
                cha_kuwei(row.yqdhbdid);
            },
            "click #shengchengRw": function (e, value, row, index) {//行按钮生成  btn_stop
                scDialog(row.yqdhbdid);
            }
        }
        laydate.render({
            elem: '#test5'
            ,theme: '#20a0ff'
        })
        laydate.render({
            elem: '#test6'
            ,theme: '#20a0ff'
        })
        laydate.render({
            elem: '#test7'
            ,theme: '#20a0ff'
        })
        laydate.render({
            elem: '#test8'
            ,theme: '#20a0ff'
        })
        var $table = zzpUtils.table({
            elem: '#table',
            isApi: true,
            pagination:true,
            url: '/wmsshelves/list',
            columns: [
                {
                    field: '',
                    checkbox: true
                }, {
                    field: 'ckmc',
                    title: '仓库'
                }, {
                    field: 'hzmc',
                    title: '货主'
                },  {
                    field: 'asnbh',
                    title: 'ASN编号'
                },{
                    field: 'show_zjzt',
                    title: '质检状态'
                },{
                    field: 'show_asnlx',
                    title: 'ASN类型'
                },  {
                    field: 'show_asnzt',
                    title: 'ASN状态'
                },{
                    field: 'show_yxj',
                    title: '优先级'
                },{
                    field: 'cjsj',
                    title: '创建时间'
                }, {
                    field: 'zdr',
                    title: '制单人'
                },  {
                    field: 'ddshr',
                    title: '审核人'
                },{
                    field: 'shsj',
                    title: '收货时间'
                },{
                    field:'caozuo',
                    title: '操作',
                    events:operateEvent,
                    formatter:operateFormatter
                }],
            queryParams: function () {//查询条件
                return  zzpUtils.getFormJson($("#searchForm"));
            },
            detailFormatter: function (index, row) {
                return "这里就没有确定过11";
            },
            onDblClickRow:function ( row,index) {/*双击行展示详情*/
                btn_cha(row.yqdhbdid);
            }
        });
        $(".inline-search-btn").on('click',function () {
            zzpUtils.refreshTable("#table");
        })
        function operateFormatter(value, row, index) {
            return [
                '<a class="layui-btn layui-btn-primary layui-btn-xs" id="searchRow" >查看</a>',
                '<a class="layui-btn layui-btn-xs" id="shengchengRw">生成</a>'
            ].join('')
        }
        /*跳生成上架任务*/
        $(".add-btn").on('click', function () {
            zzpUtils.dialog({
                title: "生成上架任务",
                type: 2,
                content: "/shelvesRouter/toAddShelvesRw",
                area: ['60%', '60%'], //设置dialog大小，也可以不设置，
                end: function () {//增加成功后刷新
                    zzpUtils.refreshTable("#table");
                }
            });
        })

        /*顶部按钮生成上架任务*/
      /*  $(".add-btn").on('click', function () {
            var $rows = $table.bootstrapTable('getSelections');
            if ($rows.length == 1) {
                var ids = $.map($rows, function (row) {
                    return row.id;
                })
                    zzpUtils.dialog({
                        title: "生成上架任务",
                        type: 2,
                        content: "/shelvesRouter/toAddShelvesRw?yqdhbdid="+yqdhbdid,
                        area: ['55%', '55%'], //设置dialog大小，也可以不设置，
                        end: function () {//修改成功后刷新
                            zzpUtils.refreshTable("#table");
                        }
                    });
            } else {
                layer.msg("请选择一条数据");
            }
        })*/
    });
    function scDialog(yqdhbdid) {
        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;
        zzpUtils.dialog({
            title: "生成上架任务",
            type: 2,
            content: "/shelvesRouter/toAddShelvesRw?yqdhbdid="+yqdhbdid,
            area: ['55%', '55%'], //设置dialog大小，也可以不设置，
        });
    }

    /*查看任务详情*/
    function cha_kuwei(yqdhbdid) {
        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;
        zzpUtils.dialog({
            title: "查看任务详情",
            type: 2,
            content: "/shelvesRouter/toChakanMx?yqdhbdid=" + yqdhbdid,
            area: ['70%', '70%'], //设置dialog大小，也可以不设置，
        });
    }
   /* /!*双击查看详情*!/
    function btn_cha(yqdhbdid){
        var zzpUtils = layui.zzpUtils,
            $ = layui.jquery,
            laydate = layui.laydate;
        zzpUtils.dialog({
            title: "预期到货通知单详情",
            type: 2,
            content: "/shelvesRouter/getFindQqxq?yqdhbdid=" + yqdhbdid,
            area: ['65%', '65%'], //设置dialog大小，也可以不设置，
        });
    }*/
</script>
</html>